package com.yasha.controller;

import java.util.ArrayList;

import org.json.JSONObject;

import com.yasha.model.HttpValues;
import com.yasha.ulti.Const;
import com.yasha.ulti.JSONParser;
import com.yasha.ulti.Tools;

public class UserController {
	private String TAG = "UserController";
	private JSONParser jParser = new JSONParser();

	public String addUserToServer(String email, String phone) {
		String result = "";
		Tools.Log(TAG, " addUserToServer");
		try {
			ArrayList<HttpValues> data = new ArrayList<HttpValues>();
			data.add(new HttpValues("userName", email));
			data.add(new HttpValues("userPhone", phone));
			JSONObject jObj = jParser.getJSONFromUrl(
					Const.addUserToServer, data);
			String status=jObj.getString("status").trim();
			if(status.equals("success"))
			{
				result=jObj.getJSONObject("user").getString("userCode").trim();
			}
		} catch (Exception e) {
			Tools.Log(TAG, " addUserToServer error: " + e.toString());
		}
		return result;
	}
}
